package com.whstudio.common.memory.item;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.w3c.dom.Document;

public abstract class AbstractBox<T extends Item> extends AbstractItem implements IBox<T>{
	public List<T> itemList=new ArrayList<T>();
	public Map<String, T> itemMap=new HashMap<String, T>();
	
	public AbstractBox(String nameString){
		super(nameString);
	}
	
	/*---------------------接口方法区--------------------------start*/
	@Override
	public void move(){
		
	}

	@Override
	public void addItem(T t) {
		String keyString=t.getName();
		if(itemMap.containsKey(keyString)){
			return;
		}
		itemList.add(t);
		itemMap.put(keyString, t);
	}
	@Override
	public T getItem(String itemNameString) {
		return itemMap.get(itemNameString);
	}
	@Override
	public List<T> getItemList() {
		return itemList;
	}
	@Override
	public Map<String, T> getItemMap() {
		return itemMap;
	}
	@Override
	public Document getItemPack() {
		return null;
	}
	@Override
	public String getName() {
		return getNameString();
	}
	@Override
	public List<T> sortByName(Boolean reverseBoolean) {
		return itemList;
	}
	/*---------------------接口方法区--------------------------end*/
}
